package duck;

/**
 * 北京鸭子类
 */
public class PekingDuck extends Duck {

    public PekingDuck() {
        super("白色", 2.5);
    }

    public PekingDuck(double heavy) {
        super("白色", heavy);
    }

    @Override
    public void fly() {
        System.out.println("北京鸭在低空缓慢飞行");
    }

    @Override
    public void quack() {
        System.out.println("北京鸭发出低沉的'呱呱呱'叫声");
    }

    // 重载setHeavy方法
    public void setHeavy(double[] weights) {
        if (weights.length > 0) {
            double sum = 0;
            for (double w : weights) {
                sum += w;
            }
            this.heavy = sum / weights.length;
            System.out.println("重载方法: 设置北京鸭平均体重为: " + this.heavy + "kg");
        }
    }

    public void setHeavy(double minWeight, double maxWeight) {
        this.heavy = (minWeight + maxWeight) / 2;
        System.out.println("重载方法: 设置北京鸭体重范围为 " + minWeight + "-" + maxWeight + "kg，平均: " + this.heavy + "kg");
    }

    @Override
    public void display() {
        System.out.println("=== 北京鸭信息 ===");
        super.display();
        System.out.println("北京鸭是著名的肉用鸭品种");
    }
}